/**
 * Created by hxs 
 */
 
 function get_index_echarts(){
	 
	    var myChart = echarts.init($("#container16")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:40,
                borderWidth: 0
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    data:ydata.sk_x,

                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'center'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            series : [
                {
                    name:'触发事件个数',
                    type:'bar',
                    barWidth:'30',
                    data:ydata.sk_y,
                    itemStyle: {
                        normal: {
                            color:"#0aff6c"
                        }
                    }

                }
            ]
        };
        myChart.setOption(option);
 }

 
 function get_bie_echarts(){
	 var myChart = echarts.init($("#container_huan")[0]);
     var option = {
         tooltip: {
             trigger: 'item',
             formatter: "{a} <br/>{b}: {c} ({d}%)"
         },
         legend: {
             orient: 'vertical',
             x: 'left',
             data:ydata.sb_name,
             textStyle:{
                 color:"#e9ebee",
                
             }
         },
         series: [
             {
                 name:'行为分析数据',
                 type:'pie',
                 center:['80%','50%'],
                 radius: ['50%', '80%'],
                 splitLine:{show: false},
                 roseType : 'area',
                 x: '50%',               // for funnel
                 max: 40,                // for funnel
                 label: {
                     normal: {
                         show: true,
                         position: 'center'
                     },
                     emphasis: {
                         show: true,
                         textStyle: {
                             fontSize: '30',
                             fontWeight: 'bold'
                         }
                     }
                 },
                 itemStyle: {
                     normal: {
                         label: {
                             show: false,
                            // formatter: '{c} ({d}%)'
                         },
                         labelLine: {
                             show: false
                         }
                     }
                 },
                 data:ydata.sb_value,
             }
         ]
     };
     myChart.setOption(option);
 }
 
 
 function get_prize_echarts(){
     var myChart = echarts.init(document.getElementById('userPrize'));
     var option = {
             tooltip : {
                 trigger: 'axis',
                 axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                     type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                 }
             },
             grid: {
                 x: 46,
                 y:30,
                 x2:32,
                 y2:40,
                 borderWidth: 0
             },
             xAxis:  {
                 type: 'value',
                 x:'180',
                 splitLine: {
                     show: false
                 },
                 axisLabel: {
                     show: true,
                     textStyle: {
                         color: '#a4a7ab'
                     }
                 }
             },
             yAxis: {
                 type: 'category',
                 data: ydata.tdname,
                 splitLine: {
                     show: false
                 },
                 axisLabel: {
                     show: true,
                     textStyle: {
                         color: '#a4a7ab',
                         fontSize: 9
                     }
                 }
             },
             series: [
                 {
                     name: '事件发生数量',
                     type: 'bar',
                     stack: '总量',
                     label: {
                         normal: {
                             show: true,
                             position: 'insideRight'
                         }
                     },
                     data: ydata.tdnum,
                     itemStyle: {
                         normal: {
                             color:"#45c0ff"
                         }
                     }
                 }
             ]
         };


     myChart.setOption(option);
 }
 
 function BootstrapTable_t() {
     $('#table').bootstrapTable({
         method: "get",
         striped: true,
         singleSelect: false,
         url: "/api/AI_Bigscreen/get_event_mx",
         dataType: "json",
         pagination: true, //分页
         pageSize: 5,
         pageNumber: 1,
         search: false, //显示搜索框
         contentType: "application/x-www-form-urlencoded",
         queryParams: queryParams,
         columns: [
             {
                 title: '事件',
                 field: 'title',
                 width:75,
                 align: 'center',
                 valign: 'middle'
             },

             {
                 title: '设备token',
                 field: 'deviceToken',
                 width:70,
                 align: 'center'
             },

             {
                 title: '事件发生地点',
                 field: 'sjaddress',
                 width:60,
                 align: 'center'
             },
             {
                 title: '抓拍时间',
                 field: 'rtime',
                 width:120,
                 align: 'center'
             },
             {
                 title: '操作',
                 field: 'eventId',
                 width:40,
                 align: 'center',
                 formatter: function (value, row) {
                     //console.log(value);
                     var e = '<a  href="javascript:void(0)" title="" onclick="get_ai_pic(\''+value+'\')">详情</a> ';
                     return e;
                 }
             }

         ]
     });

 }
 
 function get_ai_pic(all_id){
     //alert(rootpath+'/extr_bai_eventControl/get_other_pic');
     //console.log(all_id);
     //return;
	 $("#extr_body_bai_event").html("");
	
	$.ajax({
		dataType : "json",
        url: "/api/AI_Bigscreen/get_other_pic",
		type : "post",
		data : {
           eventid : all_id,
		},
success : function(rtn) {
    var t = "";
    console.log("ooooo");
    //return;
if (rtn) {
	for(var i=0;i<=rtn.result_list.length-1;i++){
		t=$("#pic_model_display").html();
        t = t.replace(/@createTime@/g, rtn.result_list[i].createTime);	
		t=t.replace(/@eventId@/g,rtn.result_list[i].eventId.split('_')[2]);	
        t = t.replace(/@deviceName@/g,rtn.result_list[i].deviceName);	
        t = t.replace(/@requestTime@/g, rtn.result_list[i].requestTime);	
		t = t.replace(/@eventId@/g,rtn.result_list[i].eventId);	
		t = t.replace(/@skillName@/g,rtn.result_list[i].skillName);	
        t = t.replace(/@savapicpath@/g, rtn.base64);
        t = t.replace(/@o_savapicpath@/g, rtn.base64_o);
		
		$("#extr_body_bai_event").append(t);
	}

	//console.log(rtn.result_list.length-1);
		
}
}
});
	
//	$('#my_extr_bai_event').modal('toggle'); //对模态窗体控制开关
     $('#operator_type_bai_event').text("事件ID:"+all_id);
	 openDiv();
	  //  alert(id);	
	//	$('#my_extr_bai_event').modal('toggle'); //对模态窗体控制开关
	//	$('#operator_type_bai_event').text(id);
 }
 
 /*动态添加table
  * */
 function get_frist_data(){
     //console.log(ydata.todate_count[0]);
	 for(var i=0;i<=ydata.dongdao_list.length-1;i++){
		 var x=document.getElementById("tongdao001").insertRow(-1);
		 var y=x.insertCell(0);
		 var z=x.insertCell(1);
		 y.innerHTML=ydata.dongdao_list[i].deviceToken;
		 z.innerHTML=ydata.dongdao_list[i].sjaddress;
		 y.colSpan=2;
		 z.colSpan=2;
	 }
	 document.getElementById("zongs").innerHTML=ydata.zong_count[0].co;
	 document.getElementById("todate_zongs").innerHTML=ydata.todate_count[0].co;
	 document.getElementById("dt_zongs").innerHTML=ydata.dongdao_list.length;//通道个数
	 document.getElementById("jl_zongs").innerHTML=ydata.jileng_list.length;//技能个数jileng_list 
}


function get_next_pic(fx) {

    //console.log($('#operator_type_bai_event').html().split(':')[1]);
    //return;
    $("#extr_body_bai_event").html("");

    $.ajax({
        dataType: "json",
        url: "/api/AI_Bigscreen/get_next_pic",
        type: "post",
        data: {
            eventid: $('#operator_type_bai_event').html().split(':')[1],
            fx:fx,//next,pre
        },
        success: function (rtn) {
            var t = "";
            //console.log("ttt");
            //return;
            if (rtn.result_list) {
                t = $("#pic_model_display").html();
                t = t.replace(/@createTime@/g, rtn.result_list.createTime);
                t = t.replace(/@eventId@/g, rtn.result_list.eventId.split('_')[2]);
                t = t.replace(/@deviceName@/g, rtn.result_list.deviceName);
                t = t.replace(/@requestTime@/g, rtn.result_list.requestTime);
                t = t.replace(/@eventId@/g, rtn.result_list.eventId.split('_')[2]);
                t = t.replace(/@skillName@/g, rtn.result_list.skillName);
                t = t.replace(/@savapicpath@/g, rtn.base64);
                t = t.replace(/@o_savapicpath@/g, rtn.base64_o);
                $("#extr_body_bai_event").append(t);
                //console.log(rtn.result_list.length-1);
                $('#operator_type_bai_event').text("事件ID:" + rtn.result_list.eventId);
            }
        }
    });

   
   
}


